<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <title>按药品查看</title>
    <%@ include file="/WEB-INF/component/commonCSS.jsp"%>
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
							
    <section class="content-header">
        <h1>分院采购情况查看</h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
            <li class="active"><a href="#">采购计划管理</a></li>
            <li class="active"><a href="#">分院采购情况查看</a></li>
        </ol>
    </section>
    
    <section class="content">
        <div class=" box box-success">
            <div class="box-body">
            	<div class="input">
            		<div class="textalign1">药品编码：</div>
            		<div class="boxinput">
            			<input class="textinput" type="text" id="searchDrugCode" placeholder="药品编码" maxlength="18" />
            		</div>
            		<div class="textalign1">通用名：</div>
            		<div class="boxinput">
            			<input class="textinput" type="text" id="searchDrugName" placeholder="通用名" maxlength="127" />
            		</div>
            		<div class="textalign1">生产企业：</div>
            		<div class="boxinput">
            			<input class="textinput" type="text" id="searchCompName" placeholder="生产企业" maxlength="127" />
            		</div>
            		<div class="textalign1">
            			<button type="button" class="btn btn-success btn-sm" onclick="search();" id="selectc">查询</button>
            		</div>
            	</div>
            </div>
        </div>
        
        <table class="jqgrid" id="gridlist"></table>
        <div id="gridpage"></div>
        
        <div class=" box box-warning bottongroup">
        	<a href="${ctx}/bidHospplan/toBidChildHospPlanList.html" class="btn btn-default btn-sm">返 回</a>
        </div>
    </section>
    <%@ include file="/WEB-INF/component/commonJS.jsp"%>
    <script type="text/javascript">
	    //绑定回车
	    $('#searchDrugCode,#searchDrugName,#searchCompName').bind('keydown', function(event) {
	        if (event.keyCode == "13") {        //13 位电脑上回车键的位置代码
	            $('#selectc').click();
	        }
	    }); 
			
	    $("#searchDrugCode").focus();//加载页面光标在第一个查询框内
    
    	function search(page) {
    		var searchDrugCode = $("#searchDrugCode").val();
    		var searchDrugName = $("#searchDrugName").val();
    		var searchCompName = $("#searchCompName").val();
    		
    		$("#gridlist").jqGrid('setGridParam',{  
    	        datatype:'json',
    	        postData:{"drugCode":searchDrugCode, "drugName":searchDrugName, "compName":searchCompName},
    	        page : (page || 1)
    	    }).trigger("reloadGrid"); //重新载入  
    	}
    
        $(function () {
            
            $("#gridlist").jqGrid({
                url: "${pageContext.request.contextPath}/bidHospplan/getChildHospDrugList.html",
                mtype: "post",
                datatype: "json",
                postData: {"projId":"${projId}"},
                autowidth: true,
                height: 270,
                colNames: [
                    'projId',
                    'drugId',
					'药品编码', 
					'通用名',
					'剂型',
					'规格', 
					'转换系数',
					'单位',
					'材质',
					'生产企业',
					'已申报医疗机构数'
                ],
                colModel: [
                    { name: 'proId', hidden:true, width: 10, align:"center", sortable: false},
                    { name: 'drugId', hidden:true, width: 10, align:"center", sortable: false},
                    { name: 'drugCode', width: 10, align:"center", sortable: false,
                        formatter:function(cellvalue, options, row){
                            return "<a href=\"javascript:void(0)\" onclick=\"showDrugInfo('"+row.drugCode+"','"+row.drugName+"')\">"+cellvalue+"</a>";		
                        }
                    },
                    { name: 'drugName', width: 15, align:"center", sortable: false },
                    { name: 'formName', width: 9, align:"center", sortable: false},
                    { name: 'specName', width: 10, align:"center", sortable: false},
                    { name: 'factor', width: 5, align:"center", sortable: false},
                    { name: 'unit', width: 5, align:"center", sortable: false},
                    { name: 'materialName', width: 6, align:"center", sortable: false},
                    { name: 'compName', width: 20, align:"center", sortable: false,
                    	 formatter:function(cellvalue, options,row) {
                    		 return "<a href=\"javascript:void(0)\" onclick=\"showCompInfo('"+row.compId+"','"+row.compName+"')\">"+cellvalue+"</a>";		
			     		}
                    },
                    { name: 'hospCount', width: 10, align:"center", sortable: false,formatter:displayLink}
                ],
                rowNum: 20,
                rowList: [10, 20, 50, 100],
                rownumbers: true,
                pager: "#gridpage",
                viewrecords: true,
                caption: "${projName} - 按药品查看",
                jsonReader: {
                   
                },
                gridComplete: function(){
            		//序号列宽度自适应（参数为jqgridID）
                    autoRNWidth("gridlist");
                    //数据只有一条时默认选中（参数为jqgridID）
                    selectByOneData("gridlist");
            	}
            });
            function displayLink(val, opts, row){
                     	var drugData ={ "projName":"${projName}",
                     					"projId":row.projId,
                    					"drugId":row.drugId,
                    					"drugName":row.drugName,
	                        		    "formName":row.formName,
	                        			"specName":row.specName,
	                        			"factor":row.factor,
	                        			"unit":row.unit,
	                        			"materialName":row.materialName,
	                        			"compName":row.compName}; 
                     	var data = JSON.stringify(drugData);
                        return "<a href='javascript:void(0)'  onclick='toPlanListByDrug("+data+");' >" + val + "</a>";
            }
            $("#gridlist").jqGrid('navGrid', '#gridpage', { add: false, edit: false, del: false, search: false, refresh: false });
            $(window).trigger("resize");
        });
        function toPlanListByDrug(drugData){
        	post('toChildHospPlanByDrugDetail.html', drugData);  
        }
        function post(URL, PARAMS) {        
            var temp = document.createElement("form");        
            temp.action = URL;        
            temp.method = "post";        
            temp.style.display = "none";        
            for (var x in PARAMS) {        
                var opt = document.createElement("textarea");        
                opt.name = x;        
                opt.value = PARAMS[x];        
                temp.appendChild(opt);        
            }        
            document.body.appendChild(temp);        
            temp.submit();        
            return temp;        
        } 
    </script>
</body>
</html>